import React, { Component } from 'react'
import {debounce} from "lodash"
import axios from "axios"
import { Form, Input, Button, Checkbox } from 'antd';
import { message} from 'antd';
const Demo = (props) => {
  const onFinish = (values) => {
    console.log('Success:', values);
    axios.post("/login1",{
     
        values
      
    }).then(res=>{
        if (res.data.code == 0 ) {
          message.error('用户名密码错误');
        }
        if (res.data.code == 1) {
          message.success('登陆成功');
            localStorage.setItem("islogin","true")
            window.localStorage.setItem("username","赵志豪")
            setTimeout(()=>{
               props.history.push({
                    pathname:"/all",
                    state:{
                      username:"lisi"
                    }
               })
             
            },200)
        }
    })
   
  };

  const onFinishFailed = (errorInfo) => {
    console.log('Failed:', errorInfo);
  };

  return (
    <Form
      name="basic"
      labelCol={{
        span: 8,
      }}
      wrapperCol={{
        span: 8,
      }}
      initialValues={{
        remember: true,
      }}
      onFinish={onFinish}
      autoComplete="off"
    >
      <Form.Item
        label="Username"
        name="username"
        rules={[
          {
            required: true,
            message: 'Please input your username!',
          },
        ]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label="Password"
        name="password"
        rules={[
          {
            required: true,
            message: 'Please input your password!',
          },
        ]}
      >
        <Input.Password />
      </Form.Item>


      <Form.Item
        wrapperCol={{
          offset: 8,
          span: 16,
        }}
      >
        <Button type="primary" htmlType="submit">
            登陆
        </Button>
      </Form.Item>
    </Form>
  );
};

export default Demo;

